﻿#ifndef MATHVECTOR2D_H_INCLUDED
#define MATHVECTOR2D_H_INCLUDED

#include <cmath>

template <class T>
class MathVector2d {
    private:
        T x, y;
    public:
        T get_x() const{ return x; }
        T get_y() const{ return y; }

        void set_x( const T& a ) { x = a; }
        void set_y( const T& a ) { y = a; }

            // creates a vector from a pair of objects
        MathVector2d( const T& a, const T& b )
            :x( a )
            ,y( b )
        {}

        T length() const; // vector length
};

  // vectors angle cosine
template<class T>
T cos( const MathVector2d<T>& a, const MathVector2d<T>&b );

  // vector sum
template<class T>
MathVector2d<T> operator + ( const MathVector2d<T>& a, const MathVector2d<T>& b );

  // vector margin
template<class T>
MathVector2d<T> operator - ( const MathVector2d<T>& a, const MathVector2d<T>& b );

  // scalar product
template<class T>
T operator * ( const MathVector2d<T>& a, const MathVector2d<T>& b );

  // vector multyplied by number
template<class T>
MathVector2d<T> operator * ( const MathVector2d<T>& a , const float& b );

template<class T>
MathVector2d<T> operator * ( const float& b, const MathVector2d<T>& a );

template<class T>
MathVector2d<T> operator / ( const MathVector2d<T>& a, const float& b );

  // if vectors are same returns true else returns false
template<class T>
bool operator == ( const MathVector2d<T>& a, const MathVector2d<T>& b );

  // if vectors aren't same returns true else returns false
template<class T>
bool operator != ( const MathVector2d<T>& a, const MathVector2d<T>& b );

  // projection of vector a on vector b
template<class T>
MathVector2d<T> projection( const MathVector2d<T>& a, const MathVector2d<T>& b );

  // sets vector's length to b
template<class T>
MathVector2d<T> set_length( const MathVector2d<T>& a, const float& b );

#endif // MATHVECTOR2D_H_INCLUDED
